﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace XZTZ.UMP.WEB.Data.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "BaseBillTemplet");

            migrationBuilder.DropTable(
                name: "BaseBillVisions");

            migrationBuilder.CreateTable(
                name: "Base_BillProperty",
                columns: table => new
                {
                    StrPropertyId = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    StrPropertyName = table.Column<string>(nullable: true),
                    DtmOperateDate = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_BillProperty", x => x.StrPropertyId);
                });

            migrationBuilder.CreateTable(
                name: "Base_BillVision",
                columns: table => new
                {
                    GuidBillVisionId = table.Column<Guid>(nullable: false),
                    StrVisionName = table.Column<string>(maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_BillVision", x => x.GuidBillVisionId);
                });

            migrationBuilder.CreateTable(
                name: "Base_CompanyType",
                columns: table => new
                {
                    guidCompanyTypeID = table.Column<Guid>(nullable: false),
                    strTypeCode = table.Column<string>(maxLength: 2, nullable: false),
                    strTypeName = table.Column<string>(maxLength: 20, nullable: false),
                    dtmOperateDate = table.Column<DateTime>(nullable: false),
                    intIndexNo = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    blnTabooFlag = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_CompanyType", x => x.guidCompanyTypeID);
                });

            migrationBuilder.CreateTable(
                name: "Bid_ProjectInfo",
                columns: table => new
                {
                    ProjectID = table.Column<Guid>(nullable: false),
                    AreaInfo = table.Column<string>(nullable: true),
                    BeginDate = table.Column<DateTime>(nullable: false),
                    BeginStake = table.Column<string>(nullable: true),
                    BillVision = table.Column<Guid>(nullable: false),
                    BredgeNum = table.Column<string>(nullable: true),
                    ConfiremedMonth = table.Column<decimal>(nullable: false),
                    ConfirmedYear = table.Column<decimal>(nullable: false),
                    ConstructNo = table.Column<string>(nullable: true),
                    CulvertLen = table.Column<string>(nullable: true),
                    DocHttpURLAddress = table.Column<string>(nullable: true),
                    EndDate = table.Column<DateTime>(nullable: false),
                    EndStake = table.Column<string>(nullable: true),
                    FactInvest = table.Column<decimal>(nullable: false),
                    FactLength = table.Column<decimal>(nullable: false),
                    FlowVision = table.Column<Guid>(nullable: false),
                    IsOut = table.Column<bool>(nullable: false),
                    IsSubmited = table.Column<bool>(nullable: false),
                    MasterCompany = table.Column<string>(nullable: true),
                    Note = table.Column<string>(nullable: true),
                    OperateDate = table.Column<DateTime>(nullable: false),
                    Operator = table.Column<string>(nullable: true),
                    PlanInvest = table.Column<decimal>(nullable: false),
                    PlanLength = table.Column<decimal>(nullable: false),
                    PrimaryNo = table.Column<string>(nullable: true),
                    ProjectName = table.Column<string>(nullable: true),
                    ReplayBudgetary = table.Column<decimal>(nullable: false),
                    ReplaySchematic = table.Column<decimal>(nullable: false),
                    ReportVision = table.Column<Guid>(nullable: false),
                    RootDirAddress = table.Column<string>(nullable: true),
                    ShortNameCH = table.Column<string>(nullable: true),
                    ShortNameCN = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Bid_ProjectInfo", x => x.ProjectID);
                });

            migrationBuilder.CreateTable(
                name: "Base_BillTemplet",
                columns: table => new
                {
                    GuidBillId = table.Column<Guid>(nullable: false),
                    GuidParentId = table.Column<Guid>(nullable: false),
                    GuidBillVisionId = table.Column<Guid>(nullable: false),
                    StrType = table.Column<string>(nullable: true),
                    StrSubSortId = table.Column<string>(nullable: true),
                    StrLevelCode = table.Column<string>(nullable: true),
                    StrBillCode = table.Column<string>(nullable: true),
                    StrBillName = table.Column<string>(nullable: true),
                    StrUnit = table.Column<string>(nullable: true),
                    StrComputeType = table.Column<string>(nullable: true),
                    GuidAssociateBillId = table.Column<Guid>(nullable: true),
                    BlnIsExceed = table.Column<bool>(nullable: false),
                    StrPropertyId = table.Column<string>(nullable: true),
                    StrParentShortName = table.Column<string>(nullable: true),
                    IntIndexNo = table.Column<int>(nullable: false),
                    DtmOperateDate = table.Column<DateTime>(nullable: false),
                    BlnTabooFlag = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Base_BillTemplet", x => x.GuidBillId);
                    table.ForeignKey(
                        name: "FK_Base_BillTemplet_Base_BillVision_GuidBillVisionId",
                        column: x => x.GuidBillVisionId,
                        principalTable: "Base_BillVision",
                        principalColumn: "GuidBillVisionId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Base_BillTemplet_GuidBillVisionId",
                table: "Base_BillTemplet",
                column: "GuidBillVisionId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Base_BillProperty");

            migrationBuilder.DropTable(
                name: "Base_BillTemplet");

            migrationBuilder.DropTable(
                name: "Base_CompanyType");

            migrationBuilder.DropTable(
                name: "Bid_ProjectInfo");

            migrationBuilder.DropTable(
                name: "Base_BillVision");

            migrationBuilder.CreateTable(
                name: "BaseBillVisions",
                columns: table => new
                {
                    GuidBillVisionId = table.Column<Guid>(nullable: false),
                    StrVisionName = table.Column<string>(maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BaseBillVisions", x => x.GuidBillVisionId);
                });

            migrationBuilder.CreateTable(
                name: "BaseBillTemplet",
                columns: table => new
                {
                    GuidBillId = table.Column<Guid>(nullable: false),
                    BlnIsExceed = table.Column<bool>(nullable: false),
                    BlnTabooFlag = table.Column<bool>(nullable: false),
                    DtmOperateDate = table.Column<DateTime>(nullable: false),
                    GuidAssociateBillId = table.Column<Guid>(nullable: true),
                    GuidBillVisionId = table.Column<Guid>(nullable: false),
                    GuidParentId = table.Column<Guid>(nullable: false),
                    IntIndexNo = table.Column<int>(nullable: false),
                    StrBillCode = table.Column<string>(nullable: true),
                    StrBillName = table.Column<string>(nullable: true),
                    StrComputeType = table.Column<string>(nullable: true),
                    StrLevelCode = table.Column<string>(nullable: true),
                    StrParentShortName = table.Column<string>(nullable: true),
                    StrPropertyId = table.Column<string>(nullable: true),
                    StrSubSortId = table.Column<string>(nullable: true),
                    StrType = table.Column<string>(nullable: true),
                    StrUnit = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BaseBillTemplet", x => x.GuidBillId);
                    table.ForeignKey(
                        name: "FK_BaseBillTemplet_BaseBillVisions_GuidBillVisionId",
                        column: x => x.GuidBillVisionId,
                        principalTable: "BaseBillVisions",
                        principalColumn: "GuidBillVisionId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_BaseBillTemplet_GuidBillVisionId",
                table: "BaseBillTemplet",
                column: "GuidBillVisionId");
        }
    }
}
